<?php

function select_print_works($bdd) {

    $results = $bdd->query('SELECT * FROM `works`');

    return $results;
}
function model_search_optgroup_works($choice_slide, $bdd)
{

     $req = $bdd->query("SELECT id_work FROM `works`
         WHERE work_name = '$choice_slide'");

  $count = $req->rowCount();
    return $count;
    
}

function model_search_optgroup_news($choice_slide, $bdd)
{ 
     $results = $bdd->query('SELECT id_new FROM `news`
         WHERE new_name = '.$choice_slide.'');

    return $results;
    
}


function select_print_news($bdd) {

    $results = $bdd->query('SELECT new_name FROM `news`');

    return $results;
}

function model_delete_slide($bdd) {
    $bdd->query('DELETE FROM slide');
}

function model_insert_slide($bdd, $i, $choice_slide, $type) {
    $req = $bdd->prepare('INSERT INTO slide(slide_name,num_slide,type) 
        VALUES(:slide_name,:num_slide,:type)
        ');
    $req->execute(array(
        'slide_name' => $choice_slide,
        'num_slide' => $i,
        'type' => $type
    ));
}

function select_slide($bdd, $i) {

    $results = $bdd->query("SELECT * FROM `slide`
        WHERE num_slide = $i");

    return $results;
}

function model_add_extra($bdd, $name, $type_img) {

    $req = $bdd->prepare('INSERT INTO news(name,type_img) 
        VALUES(:name,:type_img)');
    $req->execute(array(
        'name' => $name,
        'type_img' => $type_img
    ));
}

function count_extra($bdd) {
    $req = $bdd->query('SELECT id FROM extra');
    $count = $req->rowCount();
    return $count;
}

?>
